import { Input, Menu, Dropdown, Icon, List, Avatar, Button, Carousel, Select, notification } from 'antd';
import { css } from 'jquery';
import React, { useState, useRef, useEffect } from 'react';

import moment from 'moment'
import 'moment/locale/zh-cn'
moment.locale('zh-cn')
import {
  SmileOutlined, CryOutlined
} from '@ant-design/icons';
var storage = window.localStorage;

/**
 * 
 * @param {Array} selectedRows 
 * @param {Array} printColumn 
 * @returns 
 */
export function selectedRows_to_printColumn(selectedRows, printColumn) {
  for (var i = 0; i < printColumn.length; i++) {
    printColumn[i].value = selectedRows[0][printColumn[i].key]
  }
  return printColumn
}



/**
 * 替换value中的${a}为variables中的a的值
 * @param {string} value 
 * @param {array} variables 
 * @returns 
 */
export function replace_value_util(value, variables) {
  for (let i = 0; i < variables.length; i++) {
    let variName = variables[i].label;
    let variValue = variables[i].value;
    //将b中的${variName}替换成variValue
    let regexString = `\\$\\{${variName}\\}(&nbsp;?.)*`;// 包含前后的 \\s* 来匹配多个nbsp; 
    let match=value.match(regexString);
    let nbspCount=countNbsp(match[0]);//计算nbsp; 的个数
    // console.log(nbspCount, "nbspCount");
    // console.log(variValue.length, "variValue.length");
    let replaceString=variValue;
    let num=nbspCount-variValue.length;
    for (let index = 0; index < num-3; index++) {
      replaceString+="&emsp;";
    }
    replaceString+="&ensp;"
    // console.log(replaceString);
    let finalRegex = new RegExp(regexString, 'g'); // 创建正则表达式对象
    value = value.replace(finalRegex, replaceString);
  }
  return value
}

function countNbsp(input) {
  const nbspMatches = input.match(/&nbsp;/g);
  return nbspMatches ? nbspMatches.length : 0;
}



//改成view_item_util
export function view_item_util(colmuns) {
  colmuns.forEach(col => {
    if (col.inputType == "upload_fj_item" || col.inputType == "view_fj_item") {
      col.inputType = "view_fj_item"
    }
    else if (col.inputType == "input_text_item") {
      col.inputType = "view_text_item"
    }
    else if (col.inputType == "cz_item") {
      col.inputType = "cz_item"
    }
    else if (col.inputType == "readonly" || col.inputType == "none") {
      col.inputType = col.inputType
    }
    else {
      col.inputType = "view_item"
    }
  })
  return colmuns
}


//带有回调的usestate
export function useCallbackState(od) {
  const cbRef = useRef();
  const [data, setData] = useState(od);
  useEffect(() => {
    cbRef.current && cbRef.current(data);
  }, [data]);

  return [
    data,
    function (d, callback) {
      cbRef.current = callback;
      setData(d);
    }
  ];
}



//通用弹窗 2023-08-19
export function openNotification_util(text, cry) {
  notification.config({
    maxCount: 2,
    duration: 3,
  })
  notification.open({
    message: '提示', description: text, onClick: () => { },
    icon: (
      cry ?
        <SmileOutlined
          style={{
            color: '#e61029',
          }}
        /> :
        <SmileOutlined
          style={{
            color: '#108ee9',
          }}
        />
    ),
  })
}



//判断查询字段数组  keyarr:需要校验字符数组 ，checkobj 需要校验的对象  2023-08-19
export function checkdatavalid_util(keyarr, checkobj) {
  for (let item of keyarr) {    //for of 推荐用在遍历数组
    var checkvalue = checkobj[item]
    if (checkvalue == "" || checkvalue == null || checkvalue == undefined)
      return false;
  }
  return true;
}

/**
 * 
 * @param {Array} arr 明细数组 
 * @returns  如果明细数组中校验不成功返回false，否则返回true
 */
export function checkdatavalid_util_formdata_mx(arr) {
  let mxdatachecktemp = 0;
  arr.forEach(mjmxitem => {
    var checkobj = checkdatavalid_util_formdata(mjmxitem)
    //openNotification_util(checkobj.rtmessage);
    if (!checkobj.rtstatus) { mxdatachecktemp++ }
    else;
  })
  return mxdatachecktemp==0
}

//    2023-10-31
export function checkdatavalid_util_formdata(formdata) {

  var temp = true
  var rtmessage = ""
  for (var key in formdata) {
    if (formdata[key].bt) {
      var checkvalue = formdata[key].value
      if (checkvalue === "" || checkvalue === null || checkvalue === undefined) {
        temp = false;
        rtmessage = `${rtmessage} "${formdata[key].title}" `
      }
      else { }
    }
    else { }
  }

  temp ? rtmessage = "表单数据验证通过！" : rtmessage = rtmessage + "没填写，请检查表单"
  return { rtstatus: temp, rtmessage: rtmessage };
}


//判断查询字段数组  keyarr:需要校验字符数组 ，checkobj 需要校验的对象  2023-08-19
export function checkdatavalid_util_pure(keyarr) {
  for (let item of keyarr) {    //for of 推荐用在遍历数组
    if (item == "" || item == null || item == undefined)
      return false;
  }
  return true;
}


/**
 * //这个日期字符串获取更好用，根据需求返回三种1：年月日 2年月日时分秒 31970开始时间秒数用作id  2023-08-19
 * @param {} rttype 
 * @returns 
 */
export function getCurrentDate_util(rttype) {
  var now = new Date();
  var year = now.getFullYear(); //得到年份
  var month = now.getMonth();//得到月份
  var date = now.getDate();//得到日期
  var day = now.getDay();//得到周几
  var hour = now.getHours();//得到小时
  var minu = now.getMinutes();//得到分钟
  var sec = now.getSeconds();//得到秒
  month = month + 1;
  if (month < 10) month = "0" + month;
  if (date < 10) date = "0" + date;
  if (hour < 10) hour = "0" + hour;
  if (minu < 10) minu = "0" + minu;
  if (sec < 10) sec = "0" + sec;
  var time = "";
  //精确到天
  if (rttype == 1) {
    time = year + "-" + month + "-" + date;
  }
  //精确到分
  else if (rttype == 2) {
    time = year + "-" + month + "-" + date + " " + hour + ":" + minu + ":" + sec;
  }
  else if (rttype == 3) {
    time = now.getTime();
  }
  else if (rttype == 4) {
    time = year + "--" + month + "--" + date;
  }
  else if (rttype == 5) {
    time = year + "" + month + "" + date;
  }

  return time;
}


/**通用请求 fetchsync_util
 * url 地址, type 类型[POST/GET], param 值, rttype  返回类型
 */
export async function fetchsync_util(url, type, param, rttype) {
  param.storage = {
    ygxm: storage.ygxm, ygbh: storage.ygbh, bb: storage.loginbb,yhlx:storage.yhlx,
    cx: storage.logincx, logincx: storage.logincx, loginbb: storage.loginbb,
    userid: storage.userid
  }
  // //console.log("param.storage",param.storage)
  return new Promise(function (resolve, reject) {
    fetch(url, {
      method: type,
      mode: 'cors',
      // credentials: 'include',
      headers: {
        'Content-Type': 'application/json'
      },
      body: JSON.stringify(param)
    }
    ).then(response => {

      return rttype == "json" ? response.json() : response.text();
    }).then(data => {
      resolve(data)

    });

  })
}


/**通用请求 
 * 根据当前地址决定报表调用哪个服务
 */
export function usereporturl(url) {
  var rturl = url
  window.location.href.includes("localhost") ? "url" : rturl = "http://116.148.228.248:7777" + url
  return rturl
}



//通用数据字段为空处理,
export function dealnullorundenfined(obj) {

  const ddd = [];
  // 添加空值检查，防止 obj 为 undefined 或 null
  if (!obj || !Array.isArray(obj)) {
    return ddd;
  }
  
  for (let i = 0; i < obj.length; i++) {
    var origindata = obj[i];
    for (var keyt in origindata) {
      origindata[keyt] = origindata[keyt] || origindata[keyt] == 0 ? origindata[keyt] : ""
      origindata.key = i;
      origindata.xuhao = i + 1;
    }
    ddd.push(origindata)

  }
  return ddd

}
//通用数据字段为空处理,
export function dealnullorundenfinedmx(obj) {

  const ddd = [];
  // 添加空值检查，防止 obj 为 undefined 或 null
  if (!obj || !Array.isArray(obj)) {
    return ddd;
  }
  
  var clear = 0
  var sign = obj[0]?.ydh
  for (let i = 0; i < obj.length; i++) {
    var origindata = obj[i];

    for (var keyt in origindata) {
      origindata[keyt] = origindata[keyt] || origindata[keyt] == 0 ? origindata[keyt] : ""
      origindata.key = i;
      origindata.xuhao = i + 1 - clear;
    }
    if (obj[i]?.ydh !== sign && i !== 0) {
      clear = i
      origindata.xuhao = i + 1 - clear;
      sign = obj[i]?.ydh
    }
    ddd.push(origindata)

  }
  return ddd

}


//通用数据字段为空处理,只有报表可用，非常危险
export function dealnullorundenfined_number_danger(obj) {

  const ddd = [];
  // 添加空值检查，防止 obj 为 undefined 或 null
  if (!obj || !Array.isArray(obj)) {
    return ddd;
  }
  
  for (let i = 0; i < obj.length; i++) {
    var origindata = obj[i];
    for (var keyt in origindata) {
      origindata[keyt] = (origindata[keyt] && origindata[keyt] != '0') ? origindata[keyt] : ""
      origindata.key = i;
      origindata.xuhao = i + 1;
      origindata[keyt] = formatNumber(origindata[keyt])
    }
    ddd.push(origindata)

  }
  return ddd

}

export function formatNumber(str) {
  // 判断是否为数值或浮点数的正则表达式
  const numberRegex = /^[-+]?[0-9]+\.[0-9]+$/;

  // 判断是否符合数值或浮点数的格式
  if (numberRegex.test(str)) {
    // 转换为浮点数并保留两位小数
    const floatValue = parseFloat(str);
    const roundedValue = floatValue.toFixed(2);

    return roundedValue;
  } else {
    // 不是数值或浮点数的情况，直接返回原始字符串
    return str;
  }
}




//判断数组对象中 属性值的方法

export function hasPropertyValue_util(arr, property, value) {
  for (let i = 0; i < arr.length; i++) {
    if (arr[i].hasOwnProperty(property) && arr[i][property] === value) {
      return true; // 属性值存在
    }
  }

  return false; // 属性值不存在
}


//组合明细列头和明细数据 提交明细数据前调用
export function combile_mxdata_mxcol_util(mxdata, mxcolums) {
  var newmxdatalist = [];
  mxdata.forEach((mxitemobj, index) => {
    var newitem = {}
    for (var tkey in mxitemobj) {
      mxcolums.forEach(mxcolobj => {
        if (mxcolobj.dataIndex == tkey) {
          newitem[tkey] = { ...mxcolobj, value: mxitemobj[tkey] }
          newitem[tkey].render = null
        }
        else;
      })
    }
    newmxdatalist.push(newitem)

  })
  return newmxdatalist
}


/**
 * 
 * @param {} resultdata 
 * @param {*} formdata 
 * @returns 
 */
export function resultdata_to_formdata(resultdata, formdata) {
  for (var key in formdata) {
    formdata[key].inputType == "date_item" ? formdata[key].value = new Date() : "";
    for (var reskey in resultdata) {
      formdata[key].dataIndex == reskey ? formdata[key].value = resultdata[reskey] : "";
    }


  }

  return formdata
}



export function resultdata_to_formdataNew(resultdata, formdata) {
  let newformdata = { ...formdata }
  for (var key in newformdata) {
    newformdata[key].value = resultdata[key] ? resultdata[key] : newformdata[key].value
    newformdata[key].inputType == "date_item" ? newformdata[key].value = new Date() : "";
  }
  return newformdata
}

//为明细数据增加key字段
export function addkey_for_mxdata(mxdata) {
  mxdata.forEach((item, index) => {
    item.key = item.id
    item.xuhao = index + 1
  })
  return mxdata
}

/**
 * 2023-10-31
 * 时间格式转换 转化带t的iso日期为yyyy-mm-dd
 * @param {String} isoDateTime
 * @returns {String}
 */
export function convertISODateTimeToYYYYMMDD(isoDateTime) {

  const dateTime = new Date(isoDateTime);
  dateTime.setTime(dateTime.getTime() - 8 * 60 * 60 * 1000);

  const year = dateTime.getFullYear();
  const month = String(dateTime.getMonth() + 1).padStart(2, '0');
  const day = String(dateTime.getDate()).padStart(2, '0');

  return `${year}-${month}-${day}`;
}
/**
 * 2023-10-31
 * 时间格式转换 转化带t的iso日期为yyyy-mm-dd hh:mm:ss
 * @param {String} isoDateTime
 * @returns {String}
 */
export function convertISODateTimeToYYYYMMDDHHMMSS_notutc(isoDateTime) {

  const dateTime = new Date(isoDateTime);

  const year = dateTime.getFullYear();
  const month = String(dateTime.getMonth() + 1).padStart(2, '0');
  const day = String(dateTime.getDate()).padStart(2, '0');
  const hours = String(dateTime.getHours()).padStart(2, '0');
  const minutes = String(dateTime.getMinutes()).padStart(2, '0');
  const seconds = String(dateTime.getSeconds()).padStart(2, '0');
  return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}

/**
 * 2023-10-31
 * 时间格式转换 转化带t的iso日期为yyyy-mm-dd hh:mm:ss
 * @param {String} isoDateTime
 * @returns {String}
 */
export function convertISODateTimeToYYYYMMDDHHMMSS(isoDateTime) {

  const dateTime = new Date(isoDateTime);
  dateTime.setTime(dateTime.getTime() - 8 * 60 * 60 * 1000);

  const year = dateTime.getFullYear();
  const month = String(dateTime.getMonth() + 1).padStart(2, '0');
  const day = String(dateTime.getDate()).padStart(2, '0');
  const hours = String(dateTime.getHours()).padStart(2, '0');
  const minutes = String(dateTime.getMinutes()).padStart(2, '0');
  const seconds = String(dateTime.getSeconds()).padStart(2, '0');
  return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}

/**
 * 2023-10-31
 * 时间格式转换 转化带t的iso日期为yyyy-mm-dd hh:mm
 * @param {String} isoDateTime
 * @returns {String}
 */
export function convertISODateTimeToYYYYMMDDHHMM(isoDateTime) {
  const dateTime = new Date(isoDateTime);
  dateTime.setTime(dateTime.getTime() - 8 * 60 * 60 * 1000);

  const year = dateTime.getFullYear();
  const month = String(dateTime.getMonth() + 1).padStart(2, '0');
  const day = String(dateTime.getDate()).padStart(2, '0');
  const hours = String(dateTime.getHours()).padStart(2, '0');
  const minutes = String(dateTime.getMinutes()).padStart(2, '0');
  const seconds = String(dateTime.getSeconds()).padStart(2, '0');
  return `${year}-${month}-${day} ${hours}:${minutes}`;
}

/**
 * 2023-10-31
 * 判断数组中是否有重复的a值
 * @param {Array} arr 
 * @returns {Boolean}
 */
export function hasDuplicate_util(arr, key) {
  const valueCountMap = new Map();
  const duplicates = [];

  for (const obj of arr) {
    const value = obj[key];
    const count = valueCountMap.get(value) || 0;
    valueCountMap.set(value, count + 1);

    if (count === 1) {
      // 发现重复项
      duplicates.push({
        duplicateValue: value,
        duplicateCount: valueCountMap.get(value),
      });
    }
  }
  return duplicates;
}
/**
 * 
 * @param {*} obj 
 * @param {*} startKey 
 * @param {*} endKey 
 * @returns 
 */

export function deletePropertieswithoutkeys(obj, keepKeys) {
  var keysToDelete = Object.keys(obj).filter(key => !keepKeys.includes(key));
  keysToDelete.forEach(key => delete obj[key]);
  return obj;
}



/**
 * 
 * @param {待插入属性的原始obj} originObj 
 * @param {要插入属性起始位置} key 
 * @param {插入的对象} dynObj 
 * @returns 
 */
export function insertProperties(originObj, key, insertObj) {
  const objectMap = new Map(Object.entries(originObj));
  const keys = Array.from(objectMap.keys());

  // 确定插入位置
  const insertIndex = keys.indexOf(key);

  // 在指定位置插入属性
  Object.entries(insertObj).forEach(([propName, propValue]) => {
    objectMap.set(propName, propValue);
    keys.splice(insertIndex + 1, 0, propName); // 插入在指定位置之后
  });

  // 构建新对象
  const updatedObj = {};
  keys.forEach((k) => {
    updatedObj[k] = objectMap.get(k);
  });

  return updatedObj;
}


/**
 * 
 * @param { json字符串 } str 
 * @returns 
 */
export function isJSONString(str) {
  try {
    JSON.parse(str);
    return true;
  } catch (e) {
    return false;
  }
}



/**
 * 
 * @param {*待构建的树形数据} data 
 * @param {*父节点id} parentid
 * @returns {*树形数据} tree
 */
export function buildtree(data, parentid) {
  const tree = [];

  data.forEach((item) => {
    if (item.parentid === parentid) {
      const children = buildtree(data, item.id);
      const node = {
        value: item.bm,
        key: item.id,
        title: item.name,
        // selectable: item.parentid=='000'?false:true,
        children: children.length > 0 ? children : null,
      };
      tree.push(node);
    }
  });

  return tree;
}

/**
 * 构建多级树形结构（增强版）
 * @param {*待构建的树形数据} data 
 * @param {*父节点id} parentid
 * @param {*最大层级限制} maxLevel
 * @param {*当前层级} currentLevel
 * @returns {*树形数据} tree
 */
export function buildtree_free(data, parentid, maxLevel = 10, currentLevel = 0) {
  const tree = [];
  
  console.log(`buildtree_free: 构建层级 ${currentLevel}, 父节点 ${parentid}, 数据量 ${data.length}`);

  data.forEach((item) => {
    if (item.parentid === parentid) {
      console.log(`找到子节点: ${item.id} (${item.name}), 父节点: ${item.parentid}, 当前层级: ${currentLevel}`);
      
      // 检查层级限制
      if (currentLevel >= maxLevel) {
        console.warn(`达到最大层级限制 ${maxLevel}, 停止构建子节点: ${item.id}`);
        const node = {
          value: item.bm,
          key: item.id,
          title: item.name,
          children: null,
        };
        tree.push(node);
        return;
      }
      
      const children = buildtree_free(data, item.id, maxLevel, currentLevel + 1);
      const node = {
        value: item.bm,
        key: item.id,
        title: item.name,
        children: children.length > 0 ? children : null,
      };
      
      console.log(`构建节点: ${item.id} (${item.name}), 子节点数量: ${children.length}, 层级: ${currentLevel}`);
      tree.push(node);
    }
  });

  return tree;
}

/**
 * 测试多级树状结构构建
 * @param {*测试数据} testData
 * @returns {*构建结果}
 */
export function testBuildtreeFree(testData) {
  console.log('=== 开始测试 buildtree_free 函数 ===');
  console.log('测试数据:', testData);
  
  const result = buildtree_free(testData, '000', 10, 0);
  
  console.log('构建结果:', result);
  console.log('=== 测试完成 ===');
  
  return result;
}



/**
 * 
 * @param {*所选excel数据源} selectedRows 
 * @param {*excel列头数组} columnarr 
 * @param {*excel文件名} excelname 
 * @returns 
 */
export async function useexcelauto(selectedRows, columnarr, excelname) {
  var exceldata = []
  for (let item of selectedRows) {
    var obj = {}
    //console.log(item)
    for (let item2 of columnarr) {
      obj[item2.key] = item[item2.key]
    }
    exceldata.push(obj)
  }
  //console.log(exceldata)
  let rtdata = await fetchsync_util("/admin/common/export_select_auto", 'POST', {
    exceldata,
    filename: `${excelname}`, columnarr
  }, "json")
  let link = document.createElement('a')
  link.style.display = 'none'
  link.href = rtdata.url;
  link.setAttribute('download', `${excelname}.xlsx`)
  document.body.appendChild(link)
  setTimeout(() => {
    link.click();
  }, 3000);
}

export async function useexcelautoMultiple(selectedRows, columnarr, excelname) {
  var exceldata = []
  for (let item of selectedRows) {
    var obj = {}
    //console.log(item)
    for (let item2 of columnarr) {
      obj[item2.key] = item[item2.key]
    }
    exceldata.push(obj)
  }
  //console.log(exceldata)
  let rtdata = await fetchsync_util("/admin/qbmes_new/export_multiple", 'POST', {
    exceldata,
    filename: `${excelname}`, columnarr
  }, "json")
  let link = document.createElement('a')
  link.style.display = 'none'
  link.href = rtdata.url;
  link.setAttribute('download', `${excelname}.xlsx`)
  document.body.appendChild(link)
  setTimeout(() => {
    link.click();
  }, 3000);
}

export async function useexcelautoMjls(selectedRows, columnarr, excelname) {
  var exceldata = []
  var wtgData = []
  for (let item of selectedRows) {
    var obj = {}
    //console.log(item)
    for (let item2 of columnarr) {
      obj[item2.key] = item[item2.key]
    }
    exceldata.push(obj)
    wtgData.push(item.wtgzjzd)
  }
  //console.log(exceldata)
  let rtdata = await fetchsync_util("/admin/qbmes_new/export_mjls", 'POST', {
    exceldata, wtgData,
    filename: `${excelname}`, columnarr
  }, "json")
  let link = document.createElement('a')
  link.style.display = 'none'
  link.href = rtdata.url;
  link.setAttribute('download', `${excelname}.xlsx`)
  document.body.appendChild(link)
  setTimeout(() => {
    link.click();
  }, 3000);
}

export async function useexcelautoMjFQC(selectedRows, columnarr, excelname) {
  var exceldata = []
  var wtgData = []
  for (let item of selectedRows) {
    var obj = {}
    //console.log(item)
    for (let item2 of columnarr) {
      obj[item2.key] = item[item2.key]
    }
    exceldata.push(obj)
    wtgData.push(item.wtgzjzd)
  }
  //console.log(exceldata)
  let rtdata = await fetchsync_util("/admin/qbmes_new/export_MjFQC", 'POST', {
    exceldata, wtgData,
    filename: `${excelname}`, columnarr
  }, "json")
  let link = document.createElement('a')
  link.style.display = 'none'
  link.href = rtdata.url;
  link.setAttribute('download', `${excelname}.xlsx`)
  document.body.appendChild(link)
  setTimeout(() => {
    link.click();
  }, 3000);
}
/**
 * 
 * @param {*所选excel数据源} selectedRows 
 * @param {*excel列头数组} columnarr 
 * @param {*excel文件名} excelname 
 * @returns 
 */
export async function useexcelautoMain(selectedRows, columnarr, excelname) {
  var exceldata = []
  var dhbh = '('
  for (let i = 0; i < selectedRows.length; i++) {
    if (i == 0) {
      dhbh = dhbh + "'" + selectedRows[i].zdjbh + "'"
    }
    else {
      dhbh = dhbh + ",'" + selectedRows[i].zdjbh + "'"
    }
  }
  dhbh += ')'
  let rtdata = await fetchsync_util("/admin/qbmes_new/queryCkdlbAndMx", 'POST', { dhbh }, "json")
  for (let item of rtdata.resultdata) {
    var obj = {}
    //console.log(item)
    for (let item2 of columnarr) {
      obj[item2.key] = item[item2.key]
    }
    exceldata.push(obj)
  }
  console.log(exceldata)
  let rtdata2 = await fetchsync_util("/admin/qbmes_new/export_select_auto", 'POST', {
    exceldata,
    filename: `${excelname}`, columnarr
  }, "json")
  let link = document.createElement('a')
  link.style.display = 'none'
  link.href = rtdata2.url;
  link.setAttribute('download', `${excelname}.xlsx`)
  document.body.appendChild(link)
  setTimeout(() => {
    link.click();
  }, 3000);
}


/**
 * 生成短id
 * @returns  String
 */

export function useShortID() {
  const timestamp = new Date().getTime().toString(36);
  const randomString = Math.random().toString(36).substring(2, 7);
  return timestamp + randomString;
}

/**
 * 获取字典编码获取字典数据
 * @param {Array|String} zdbm 数组或者字符串
 * @returns {Object} 返回的是一个对象
 */
export async function use_dict_byzdmc(zdbm) {
  return new Promise(async (resolve, reject) => {
    let rtdata = await fetchsync_util("/admin/sys/query_dict_zdbm", 'POST', { zdbm }, "json")
    resolve(rtdata.resultdata.data)
  });

}

/**
 * 获取报表编码获取自定义报表
 * @param {Array|String} bbbm 数组或者字符串
 * @returns {Object} 返回的是一个对象
 */
export async function use_olreport_bybbbm(bbbm) {
  return new Promise(async (resolve, reject) => {
    let rtdata = await fetchsync_util("/admin/sys/query_olreport_bbbm", 'POST', { bbbm }, "json")
    resolve(rtdata.resultdata.data)
  });

}



export function usenowDate() {
  var myDate = new Date()
  return moment(myDate).format('YYYY-MM-DD HH:mm:ss')

}